package utils;

import android.content.Context;
import android.content.DialogInterface;
import android.view.View;

import com.example.xuegengwang.xuegengwang.R;

import java.util.ArrayList;
import java.util.List;

import topic.bean.TopicGroupBean;
import view.MyImageCheckedView;

/**
 * Created by Administrator on 2017/3/24.
 * 显示大图
 */

public class ShowImageUtils {
    private MyImageCheckedView dialog;

    public void showImageUtils(Context context, View view, ArrayList<TopicGroupBean.BlogListBean> arrayList, int group, int position) {
        int[] location = new int[2];
        view.getLocationInWindow(location); //获取在当前窗口内的绝对坐标
        if (dialog == null) {
            dialog = new MyImageCheckedView(context, R.style.ImageViewWatcher, arrayList.get(group).getImages(), position);
        }
        dialog.init(location[0], location[1]);
        dialog.show();
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog1) {
                dialog = null;
            }
        });
    }

    public void showImageUtils(Context context, View view, List<String> getImages, int position) {
        //view是装图片的view
        int[] location = new int[2];
        view.getLocationInWindow(location); //获取在当前窗口内的绝对坐标
        if (dialog == null) {
            dialog = new MyImageCheckedView(context, R.style.ImageViewWatcher, getImages, position);
        }
        dialog.init(location[0], location[1]);
        dialog.show();
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog1) {
                dialog = null;
            }
        });
    }

    public void showImageUtils(Context context, View view, String ImageUrl) {
        //view是装图片的view
        int[] location = new int[2];
        view.getLocationInWindow(location); //获取在当前窗口内的绝对坐标
        List<String> list = new ArrayList<>();
        list.add(ImageUrl);
        if (dialog == null) {
            dialog = new MyImageCheckedView(context, R.style.ImageViewWatcher, list, 0);
        }
        dialog.init(location[0], location[1]);
        dialog.show();
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog1) {
                dialog = null;
            }
        });
    }
}
